import http from '@ohos.net.http';
import router from '@system.router';
export default {
    data: {
        title: 'World',
        imagesrc1:"/common/gouwuche/gouwuche1.png",
        imagesrc2:"/common/shouye/shouye2.png",
        imagesrc3:"/common/shouye/shouye3.png",
        imagesrc4:"/common/gouwuche/gouwuche2.png",
        imagesrc5:"/common/shouye/shouye5.png",
        imagesrc6:"/common/gouwuche/gouwuche3.png",
        imagesrc7:"/common/gouwuche/gouwuche4.png",
        imagesrc8:"/common/gouwuche/gouwuche5.png",
        imagesrc9:"/common/gouwuche/gouwuche6.png",
        imagesrc100:"/common/gouwuche/gouwuche4.png",
        num:3,
        name:"华硕旗舰店",
        name1:"七彩虹官方旗舰店",
        space:"  >",
        shangpin1:[],
        shangpin2:[],
        total:309,
        sit1:"",
        sit2:"",
        sit3:"",
        sit4:"",
        sit5:"",
    },
    onInit(){
        this.sit1 = this.$app.$def.globalData.sit1;
        this.sit2 = this.$app.$def.globalData.sit2;
        this.sit3 = this.$app.$def.globalData.sit3;
        this.sit4 = this.$app.$def.globalData.sit4;
        this.sit5 = this.$app.$def.globalData.sit5;
        let httpRequest1 = http.createHttp();
        let httpRequest2 = http.createHttp();
        httpRequest1.request(this.$app.$def.globalData.baseURL + "/gouwuche1", {
            method: 'GET',
        }, (err, data) => {
            if (!err) {
                console.error('Result:' + data.result);
                this.shangpin1 = JSON.parse(data.result);
                console.error('Neirong:'+this.neirong1);
            } else {
                console.log('error:' + err.data);
            }
        });
        httpRequest2.request(this.$app.$def.globalData.baseURL + "/gouwuche2", {
            method: 'GET',
        }, (err, data) => {
            if (!err) {
                console.error('Result:' + data.result);
                this.shangpin2 = JSON.parse(data.result);
                console.error('Neirong:'+this.neirong1);
            } else {
                console.log('error:' + err.data);
            }
        });
    },
    onShow(){
        let httpRequest1 = http.createHttp();
        let httpRequest2 = http.createHttp();
        httpRequest1.request(this.$app.$def.globalData.baseURL + "/gouwuche1", {
            method: 'GET',
        }, (err, data) => {
            if (!err) {
                console.error('Result:' + data.result);
                this.shangpin1 = JSON.parse(data.result);
                console.error('Neirong:'+this.neirong1);
            } else {
                console.log('error:' + err.data);
            }
        });
        httpRequest2.request(this.$app.$def.globalData.baseURL + "/gouwuche2", {
            method: 'GET',
        }, (err, data) => {
            if (!err) {
                console.error('Result:' + data.result);
                this.shangpin2 = JSON.parse(data.result);
                console.error('Neirong:'+this.neirong1);
            } else {
                console.log('error:' + err.data);
            }
        });
    },
    changeshouye(){
        console.log("切换首页");
        this.$emit("changeShouYe");
    },
    changexiaoxi(){
        console.log("切换消息");
        this.$emit("changeXiaoxi");
    },
    change1(){
        if(this.imagesrc100=="/common/gouwuche/gouwuche4.png"){
            this.imagesrc100="/common/gouwuche/gouwuche5.png";
        }
        else{
            this.imagesrc100="/common/gouwuche/gouwuche4.png";
        }
    },
    jiesuanclick(){
        router.push({
            uri:"pages/jiesuan/jiesuan"
        })
    },
    goTozanweikaifang(){
        router.push({
            uri:"pages/zanweikaifang/zanweikaifang"
        })
    },
    changeguangguang(){
        console.log("切换首页");
        this.$emit("changeGuangguang");
    },
}
